#coding=utf-8

from pylab import *
from moneyflow.analyse import *

n = 20

code = '600132'
dadan = 30000
xiaodan = 1000

s = find_stock(code)
td = s.latest_td
print td
tds = td.pre_n_or_less(n-1)
tds.reverse()
tds.append(td)

tds = s.tds_between('2008-02-01', '2008-04-10')
tds.reverse()
n = len(tds)

b_s = []
for td in tds:
    
    a36 = Analyst1(td)
    a36.deals2db()
    r = a36.stats(dadan)
    
    b_s.append(r['b-s'][1])
    
#print b_s

ind = arange(n)
width = 0.35

for i in ind:
    start_point = i + width * i
    
    v = int(b_s[i]/10000)
    print tds[i], tds[i].close, v 
    
    if v >= 0:color = 'r'
    else:
        color = 'b'
                
    bar(start_point, v, width, color=color)

show()
